<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>热点热词</title>
    <link rel="stylesheet" type="text/css" href="../css/amazeui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
     <link rel="stylesheet" type="text/css" href="../css/tngou.css" />
    
</head>
<body>
	 <!-- 头部 -->	
<header data-am-widget="header" id="header"
          class="am-header am-header-default am-header-fixed"  >        
          <h1 class="am-header-title">热点热词</h1> 
</header>
 
<div class="am-margin">
<ul class="am-list" id="list">

 <!--<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left">
        <div class="am-u-sm-4 am-list-thumb">
            <img src="http://img5.douban.com/lpic/o636459.jpg" class="am-img-responsive" /> 
        </div>
        <div class=" am-u-sm-8 am-list-main">
            <h3 class="am-list-item-hd"><a href="http://www.douban.com/online/11614662/" class="">我很囧，你保重....晒晒旅行中的那些囧！</a></h3>
            <div class="am-list-item-text tngou-description">囧人囧事囧照，人在囧途，越囧越萌。标记《带你出发，陪我回家人在囧途，越囧越萌。标记《带你出发，陪我回家人在囧途，越囧越萌。标记《带你出发，陪我回家人在囧途，越囧越萌。标记《带你出发，陪我回家</div>
        </div>
      </li>-->

</ul>
</div>
      
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/amazeui.min.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript">
var page=1;
	apiready = function(){
		
			page=getList(1, 'first');	// 首次加载
			// 下拉刷新
			api.setRefreshHeaderInfo({
			    visible: true,
			    bgColor: '#ccc',
			    textColor: '#fff',
			    textDown: '下拉刷新...',
			    textUp: '松开刷新...',
			    showTime: true
			}, function(ret, err){
			    //从服务器加载数据，完成后调用api.refreshHeaderLoadDone()方法恢复组件到默认状态
			    page=getList(1, 'refresh');
			});
			
			// 页面滑动到底部加载更多
			api.addEventListener({
				name:'scrolltobottom'
			},function(ret,err){		
				if(page > 1){
					page=getList(page, 'more');
				}
			    
			})	
	};
	
	
	function getList(page, type){

	if(type == 'more'){
		api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    modal: false
		});
	}
	
	var html = '';	
	api.ajax({
   
		url: OpenAPI.top_list,
		method: 'post',
		timeout: 30,
		dataType: 'json',
		data:{
			values: {
				dataType: 'json',
				page: page
			},
		},
		returnAll:false,
	    
	},function(ret,err){
	    if (ret.status) {
	        var total=ret.total;
	    	var list =ret.tngou;
			  	for(var i=0;i<list.length;i++){
			  	  var tngou=list[i];
			  	  var img="/top/default.jpg";
			    	if(tngou.img)img=tngou.img;
			  	   html=html+'<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left">'+
				        '<div class="am-u-sm-4 am-list-thumb">'+
				           ' <img src="'+TngouImg+img+'" class="am-img-responsive" /> '+
				        '</div>'+
				        '<div class=" am-u-sm-8 am-list-main">'+
				            '<h3 class="am-list-item-hd"><a href="javascript:url(\'http://www.tngou.net/top/show/'+tngou.id+'\')" class="">'+tngou.title+'</a></h3>'+
				            '<div class="am-list-item-text tngou-description">'+tngou.description+'</div>'+
				        '</div>'+
				      '</li>';
			  	   
			  	   
			  	}
	    	
	        if(page > 1 && type=='more'){
	        	$api.append($api.dom('#list'), html);
	        }else{
	        	$api.html($api.dom('#list'), html);
	        }
	        api.parseTapmode();	        
	        if((parseInt(page)-1)*20>total)
	        {
		         api.toast({
				    msg: '数据全部加载，没有更多的数据',
				    duration:2000,
				    location: 'middle'
				});			
	        }	        
	        if(type == 'refresh'){
	        	api.refreshHeaderLoadDone();
	        }
	        

	    }else {
	        if(type == 'refresh'){
	        	api.refreshHeaderLoadDone();
	        }
			api.toast({
			    msg: '获取失败',
			    duration:2000,
			    location: 'middle'
			});
		
	    };
		api.hideProgress();
	});
    /***返回页面 */
	if(type=='more'){ return page+1;}else{return 2;}}
	
</script>
</html>